//
//  LGRedPacketViewController.m
//  LuxuryGoods
//
//  Created by 纳里健康 on 2018/6/4.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "LGRedPacketViewController.h"
#import "LGAwardAlert.h"
#import "CustomAlert.h"

@interface LGRedPacketViewController ()

@end

@implementation LGRedPacketViewController


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"领红包";
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setImage:[UIImage imageNamed:@"bottom_kefu"] forState:UIControlStateNormal];
    
    [rightBtn addTarget:self action:@selector(CallKefu) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    
    [self makeLuckView];
    
    [self makeQianDaoView];
    
    // Do any additional setup after loading the view from its nib.
    
//    NSDictionary *dict1 = @{@"moneyCount":@"2元",@"enable":@"YES",@"textColor":UIColorFromRGB(0xFFF5E2),@"image":@"Hb_red"};
    
}

- (void)makeQianDaoView
{
    NSInteger count = 5;
    CGFloat itemWidt = 60;
    CGFloat itemHeight = 80;
    CGFloat space = (SCREEN_WIDTH - count * itemWidt)/(count + 1);
    
    NSArray *imageArray = @[@"Hb_red",@"Hb_red",@"Hb_red",@"Hb_light",@"Hb_red"];
    NSArray *titleArray = @[@"第1天",@"第1天",@"第1天",@"第1天",@"第1天"];
    
    for (int i = 0 ; i < 5; i ++) {
        
        CGFloat itemX = i * itemWidt + (i + 1) * space;
        
        UIView *itemView = [[UIView alloc] initWithFrame:CGRectMake(itemX, 10, itemWidt, itemHeight)];
        
        itemView.tag = 100 + i;
        
        [self.dayView addSubview:itemView];
        
        UIImageView *tagImage = [[UIImageView alloc] initWithFrame:CGRectMake((itemWidt - 44)/2, 10, 44, 44)];
        tagImage.image = [UIImage imageNamed:imageArray[i]];
        [itemView addSubview:tagImage];
        
        UILabel *moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake((itemWidt - 44)/2 + 5, 32, 44 - 10, FONT(13).lineHeight)];
        moneyLabel.textAlignment = NSTextAlignmentCenter;
        moneyLabel.font = [UIFont systemFontOfSize:13];
        [itemView addSubview:moneyLabel];
        moneyLabel.text = @"抽奖";
        
        
        UILabel *tagLael = [[UILabel alloc] initWithFrame:CGRectMake(0, 64, itemWidt, FONT(13).lineHeight)];
        tagLael.font = [UIFont systemFontOfSize:13];
        tagLael.textAlignment = NSTextAlignmentCenter;
        [itemView addSubview:tagLael];
        tagLael.text = titleArray[i];
        
        UITapGestureRecognizer *singelTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(itemClick:)];
        
        [itemView addGestureRecognizer:singelTap];
    }
}

- (void)itemClick:(id)recognize
{
    UITapGestureRecognizer *tapClick = (UITapGestureRecognizer *)recognize;
    
    UIView *membwerView = tapClick.view;
    
    NSInteger tag = membwerView.tag - 100;
    
    NSLog(@"click At Tag == %ld",(long)tag);
    
    switch (tag) {
        case 0:
        {
            //1
            
        }
            break;
        case 1:
        {
            //鉴定
        }
            break;
        case 2:
        {
            //上新
        }
            
            break;
        case 3:
        {
            //养护
        }
            
            break;
        case 4:
        {
            //分期
        }
            break;
            
        default:
            break;
    }
    
}



- (void)makeLuckView
{
    LuckView *luckView = [[LuckView alloc] initWithFrame:CGRectMake(0, 0, _luckView.width, _luckView.height)];
    
    NSMutableArray *muArray = [[NSMutableArray alloc] init];
    
    for (int i = 0; i < 8; i ++) {
        
        UIImage *image = [UIImage imageNamed:@"cjBtnNormal"];
        
        [muArray addObject:image];
    }
    
    luckView.imageArray = muArray;
    
    luckView.stopCount = 3;
    
    [_luckView addSubview:luckView];

}

- (IBAction)lookAllMoney:(id)sender {
    
    
    
}

- (void)CallKefu
{
    //联系客服
    LGAwardAlert *alert = [[NSBundle mainBundle] loadNibNamed:@"LGAwardAlert" owner:self options:nil][0];
    alert.frame = CGRectMake(0, 0, 300, 280);
    
    [CustomAlert makeAlertWithCustomView:alert leftButtonTitle:@"知道了" rightButtonTitle:@"分享好友" leftBlock:^{
        
    } rightBolck:^{
        
    }];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
